<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>执行上下文</title>
</head>
<body>
    
</body>
<script>
    /*
    1. 依次输入什么？
    2. 整个过程产生了几个执行上下文？
    */
    console.log('global begin:' + i)
    var i = 1
    foo(1)
    function foo(i) {
        if(i == 4){
            return
        }
        console.log('foo() begin:' + i)
        foo(i + 1)
        console.log('foo() end:' + i)        
    }
    console.log('global end:' + i)


    // 变量提升、函数提升面试题
    // 测试题1
    function a(){}
    var a
    console.log('-----',typeof a) // function  先提升变量，再提升函数

    // 测试题2 
    if(!(b in window)){
        var b = 1
    }
    console.log(b) // undefined

    // 测试题3
    var c = 1
    function c(c){
        console.log(c)
    }
    c(2) // 报错 c is not a function


</script>
</html>